Skip to contentSkip to conversation

ui/cocoa.m: Adds console items to the View menu

PATCH Superseded Programmingkid 2 participants 2 messages Feb 14, 2015 – May 10, 2015 1 message not in the archive

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v3 1/1 ui/cocoa.m: Adds console items to the View menu

Adds these items to the View menu:
VGA
Monitor
Serial
Parallel

---
Removed commented out code.

 include/ui/console.h |    1 +
 ui/cocoa.m           |   60 ++++++++++++++++++++++++++++++++++++++++++++-----
 ui/console.c         |   38 +++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 7 deletions(-)
include/ui/console.h +1 -0
index 8a4d671..efe5517 100644
@@ -323,6 +323,7 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y,
                        int dst_x, int dst_y, int w, int h);
 DisplaySurface *qemu_console_surface(QemuConsole *con);
 DisplayState *qemu_console_displaystate(QemuConsole *console);
+int get_console_index(const char *name);
 
 /* sdl.c */
 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
ui/cocoa.m +53 -7

88 lines not on this page · raw message

ui/console.c +38 -0
index 87574a7..620a029 100644
@@ -2071,3 +2071,41 @@ static void register_types(void)
 }
 
 type_init(register_types);
+
+/*
+    Returns the console index associated with the name.
+    name can be graphic, monitor, serial, or parallel.
+*/
+int get_console_index(const char *name)
+{
+    int i;
+    /* If looking for the graphic console */
+    if (strcmp("graphic", name) == 0) {
+        for (i = 0; i < nb_consoles; i++) {
+            /* If we found the console */
+            if (consoles[i]->console_type == GRAPHIC_CONSOLE) {
+                return i;
+            }
+        }
+        /* If we failed to find the console */
+        return -1;
+    }
+
+    /* If looking for QEMU monitor, serial, or parallel console */
+    CharDriverState *chr;
+    for (i = 0; i < nb_consoles; i++) {
+        chr = consoles[i]->chr;
+
+        /* Can't do anything but skip it */
+        if (chr == NULL) {
+            continue;
+        }
+        /* If we found the console */
+        if (strstr(chr->label, name)) {
+            return i;
+        }
+    }
+
+    /* Could not find console */
+    return -1;
+}
Signature · 1 line
1.7.5.4
#2 lore raw
Quoted 37 lines · Programmingkid

Adds these items to the View menu:
VGA
Monitor
Serial
Parallel

ui/cocoa.m +7 -0
+// Creates the view menu
+static void create_view_menu()
+{
+    NSMenu * menu;
+    NSMenuItem * menuItem;
+    menu = [[NSMenu alloc] initWithTitle:@"View"];
+    [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen"

action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen

ui/cocoa.m +3 -0
+    [menu addItem:[NSMenuItem separatorItem]]; //Separator
+    if(get_console_index("graphic") != -1)
+        [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"VGA"

action:@selector(displayVGA:) keyEquivalent:@""] autorelease]]; // VGA

(quoted diff) +2 -0
+    if(get_console_index("monitor") != -1)
+        [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Monitor"

action:@selector(displayMonitor:) keyEquivalent:@""] autorelease]]; // QEMU Monitor

(quoted diff) +2 -0
+    if (get_console_index("serial") != -1)
+        [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Serial"

action:@selector(displaySerial:) keyEquivalent:@""] autorelease]]; // Serial

(quoted diff) +2 -0
+    if(get_console_index("parallel") != -1)
+        [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Parallel"

action:@selector(displayParallel:) keyEquivalent:@""] autorelease]]; // Parallel
+ menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil
keyEquivalent:@""] autorelease];

(quoted diff) +2 -0
+    [menuItem setSubmenu:menu];
+    [[NSApp mainMenu] insertItem: menuItem atIndex: 1]; // insert View menu

after Application menu

Review

Quoted 2 lines
(quoted diff) +2 -0
+}
+

This patch needs to be reworked to use the new qemu_console_get_label(), right?

thanks
-- PMM